package com.chen.demo.simple.appservice;

import com.chen.demo.simple.command.BookAddCommand;
import com.chen.demo.simple.command.BookDeleteCommand;
import com.chen.demo.simple.command.BookUpdateCommand;
import com.chen.demo.simple.command.query.BookPageQuery;
import com.chen.demo.simple.command.query.BookQuery;
import com.chen.demo.simple.domain.entity.Book;
import com.chen.demo.simple.handler.*;
import com.chen.winnerframework.http.response.MultiResponse;
import com.chen.winnerframework.http.response.PageResponse;
import com.chen.winnerframework.http.response.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class BookAppService {

    private final BookAddCmdExe bookAddCommandHandler;
    private final BookDeleteCmdExe bookDeleteCommandHandler;
    private final BookUpdateCmdExe bookUpdateCommandHandler;
    private final BookQryExe bookQueryHandler;
    private final BookPageQryExe bookPageQueryHandler;

    public Response addBook(BookAddCommand command) {
        return bookAddCommandHandler.execute(command);
    }

    public Response deleteBook(BookDeleteCommand command) {
        return bookDeleteCommandHandler.execute(command);
    }

    public Response updateBook(BookUpdateCommand command) {
        return bookUpdateCommandHandler.execute(command);
    }

    public MultiResponse<Book> queryBook(BookQuery query) {
        return bookQueryHandler.execute(query);
    }

    public PageResponse<Book> pageQueryBook(BookPageQuery pageQuery) {
        return bookPageQueryHandler.execute(pageQuery);
    }

}
